import ZYRequest from "./request";
import { BASE_URL } from "./request/config";
import { localCache } from "@/utils";

const zyRequest = new ZYRequest({
  baseURL: BASE_URL,
  interceptors: {
    requestInterceptor(config) {
      const token = localCache.getCache("token");

      if (token && config?.headers) {
        config.headers["Authorization"] = `Bearer ${token}`;
      }
      return config;
    },

    requestInterceptorCatch(config) {
      return config;
    },

    responseInterceptor(config) {
      return config;
    },

    responseInterceptorCatch(config) {
      return config;
    },
  },
});

export default zyRequest;
